package com.zuipin.enums;

import java.util.ArrayList;
import java.util.List;

import com.zuipin.vo.EnumVo;

/**
 * 发票类型
 * 
 * @ClassName: InvoiceType
 * @author wuyicheng
 * @time 2017年3月24日下午4:59:57
 */
public enum InvoiceType {
	NOT_INVOICE(0, "不开发票"), //
	PERSONAL(1, "个人"), //
	COMPANY(2, "公司"), //
	ELECTRONIC_INVOICE(3, "电子发票"), //
	ORDINARY_INVOICE(4, "普通发票"), //
	VTA_INVOICE(5, "增值税发票"),;
	
	// 不开发票、电子发票、普通发票、增值税发票
	
	private Integer	key;
	private String	name;
	
	InvoiceType(Integer i, String str) {
		this.key = i;
		this.name = str;
	}
	
	public Integer getKey() {
		return key;
	}
	
	public void setKey(Integer key) {
		this.key = key;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public static Integer getKeyByValue(String value) {
		if ("NOT_INVOICE".equals(value)) {
			return InvoiceType.NOT_INVOICE.getKey();
		} else if ("PERSONAL".equals(value)) {
			return InvoiceType.PERSONAL.getKey();
		} else if ("COMPANY".equals(value)) {
			return InvoiceType.COMPANY.getKey();
		} else if ("ELECTRONIC_INVOICE".equals(value)) {
			return InvoiceType.ELECTRONIC_INVOICE.getKey();
		} else if ("ORDINARY_INVOICE".equals(value)) {
			return InvoiceType.ORDINARY_INVOICE.getKey();
		} else if ("VTA_INVOICE".equals(value)) {
			return InvoiceType.VTA_INVOICE.getKey();
		}
		return null;
	}
	
	/**
	 * 获取发票类型
	 * @return
	 */
	public static List<EnumVo> findInvoiceType() {
		List<EnumVo> list = new ArrayList<>();
		list.add(new EnumVo(InvoiceType.ELECTRONIC_INVOICE.name, InvoiceType.ELECTRONIC_INVOICE.toString(), null));
		list.add(new EnumVo(InvoiceType.ORDINARY_INVOICE.name, InvoiceType.ORDINARY_INVOICE.toString(), null));
		list.add(new EnumVo(InvoiceType.VTA_INVOICE.name, InvoiceType.VTA_INVOICE.toString(), null));
		return list;
	}
	
}
